package com.hong.controller;


import com.hong.bean.RelationshipAgreement;
import com.hong.dto.relationshipagreement.CreateRelationshipAgreementParam;
import com.hong.dto.relationshipagreement.QueryRelationshipAgreementParam;
import com.hong.service.RelationshipAgreementService;
import io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@Api(value = "关系协议",tags = {"关系协议"})
@RestController
@RequestMapping("relationship/agreement")
public class RelationshipAgreementController {

    @Autowired
    private RelationshipAgreementService relationshipAgreementService;

    @ApiOperation("关系协议创建")
    @PostMapping
    public Boolean create(@RequestBody CreateRelationshipAgreementParam param){
        return relationshipAgreementService.create(param);
    }

    @ApiOperation("删除数据")
    @DeleteMapping("{id}")
    public Boolean deleteById(@PathVariable("id") Long id){
       return relationshipAgreementService.removeById(id);
    }

    @ApiOperation("恢复数据")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id",value = "协议编号",dataType = "Long",paramType = "path")
    })
    @PutMapping("{id}")
    public Boolean recoverById(@PathVariable("id") Long id){
        return relationshipAgreementService.recoverById(id);
    }

    @ApiOperation("获取协议")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id",value = "协议编号",dataType = "Long",example = "1")
    })
    @GetMapping("{id}")
    public RelationshipAgreement getById(@PathVariable("id") Long id){
        return relationshipAgreementService.getById(id);
    }

    @ApiOperation("获取协议列表")
    @GetMapping("list")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "mentorSignStatus",value = "导师签收状态",dataType = "Integer",paramType = "query",example = "0"),
            @ApiImplicitParam(name = "discipleSignStatus",value = "徒弟签收状态",dataType = "Integer",paramType = "query",example = "0"),
    })
    public List<RelationshipAgreement> getList(Integer mentorSignStatus,Integer discipleSignStatus ){
        QueryRelationshipAgreementParam param = new QueryRelationshipAgreementParam();
        param.setMentorSignStatus(mentorSignStatus);
        param.setDiscipleSignStatus(discipleSignStatus);
        return relationshipAgreementService.getList(param);
    }

}
